<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8">

	<title>Basic Javascript</title>
	
</head>
<body>
<div id="box" style="width:200px; height:200px; background:red; opacity: 1" >
</div>
	<script type="text/javascript" charset="utf-8">
		var box = document.getElementById("box");
		function fadeOut(elem, speed){
			if (!elem.style.opacity){
				elem.style.opacity = 1;
			}
			setInterval(function(){
				elem.style.opacity-= 0.02;
			}, speed/50);
		}		
		fadeOut(box, 5000);
	</script>
</body>
</html>
